package com.zgh.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zgh.domain.Province;
import com.zgh.mapper.ProvinceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ProvinceService {
    @Autowired
    private ProvinceMapper provinceMapper;

    /**
     * 根据省份名查询省份
     *
     * @param provinceName 省份名称
     * @return 省份
     */
    public Province findProvinceByName(String provinceName) {
        QueryWrapper<Province> provinceQueryWrapper = new QueryWrapper<>();
        if (!"全部".equals(provinceName)) {
            provinceQueryWrapper.eq("province", provinceName);
        }
        return provinceMapper.selectOne(provinceQueryWrapper);
    }
}
